<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <p>1212</p>
    <script>
      const p = document.querySelector("p");
      setTimeout(() => console.log(1), 0);
      // MutationObserver：观察器，内部的回调函数会被放到微队列中
      const observer = new MutationObserver(function () {
        console.log("变化了");
      });
      observer.observe(p, {
        childList: true, // 观察该元素内部的变化
      });

      p.innerHTML = 1;
      console.log(2);
    </script>
  </body>
</html>
